package com.parking.order.controller;


import com.parking.common.core.model.Result;
import com.parking.common.core.util.JwtUtil;
import com.parking.order.model.dto.FindCommentAndOrderDto;
import com.parking.order.model.dto.findMonthlyIncomeAndHourPlatformDto;
import com.parking.order.service.ICentifiedIncomeService;
import com.parking.order.service.IRentersIncomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2023年11月28日
 */
@RestController
@Api(tags = "物业日月收入统计")
@RequestMapping("/centifiedIncome")
public class CentifiedIncomeController {
    /**
     * RabbitMQ消息发送
     * */
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     * 物业日月收入统计服务层
     * */
    @Autowired
    private ICentifiedIncomeService certifiedIncomeService;

    /**
     * 测试RabbitMQ接口
     * */
    @ApiOperation("RabbitMQ测试接口")
    @GetMapping ("/testRabbitMQ")
    public void testRabbitMQ(){
        rabbitTemplate.convertAndSend("testRabbitMQ","RabbitMQ测试成功 testRabbitMQ是唯一在Controller层的消费者 其他消费者在Service层");
    }
    /**
     * 物业查询12月每日收入
     * 参数 物业token authorization
     * 返回 List<Integer> 1-31日 收入 BigDecimal->int
     * */
    @ApiOperation("物业查询12月每日收入")
    @GetMapping("/findDailyIncome.certified")
    public Result<List<Integer>> findDailyIncomeCertified(@RequestHeader String authorization) throws Exception {
        List<Integer> incomes = certifiedIncomeService.findDailyIncomeCertified(JwtUtil.getCertifiedAccountId(authorization));
        System.out.println(incomes);
        return Result.getListResult(Integer.class).setData(incomes).setMessage("物业查询12月每日收入成功");
    }

    /**
     * 物业查询12月差评未回数与超时未离开订单数
     * 参数 物业token authorization
     * 返回 badComment 差评未回数
     *     shEndOrder 超时未离开订单数
     * */
    @ApiOperation("物业查询12月差评未回数与超时未离开订单数")
    @GetMapping("/findCommentAndOrder.certified")
    public Result<FindCommentAndOrderDto> findMonthlyIncomeAndHourPlatform(@RequestHeader String authorization) throws Exception {
        FindCommentAndOrderDto dto = certifiedIncomeService.findCommentAndOrder(JwtUtil.getCertifiedAccountId(authorization));
        return Result.getResult(FindCommentAndOrderDto.class).setData(dto).setMessage("物业查询12月差评未回数与超时未离开订单数成功");
    }
}

